﻿/*
    Custom filter to return completed, not completed or all todos
*/
todoApp.filter("TodoCustomFilter", function () {
    return function (todos, filterOptions) {    
        if (filterOptions == null || filterOptions.allTodos || todos == null) {
            return todos;
        }

        var filteredTodos = [];
        for (var index = 0; index < todos.length; index++) {
            if (todos[index].Completed === filterOptions.completed) {
                filteredTodos.push(todos[index]);
            }
        }
        return filteredTodos;
    };
});

/*
    Custom filter for paging
*/
todoApp.filter('startFrom', function () {
    return function(todos, start) {
        start = +start;
        return todos.slice(start);
    };
});
